﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DimMock.Tests
{
    /// <summary>
    /// Summary description for MockTests
    /// </summary>
    [TestClass]
    public class MockTests
    {
        public MockTests()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void MockBool()
        {
            var result = Mock.Create<Boolean>();
        }

        [TestMethod]
        public void MockBoolArray()
        {
            var result = Mock.Create<Boolean[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockGuid()
        {
            var result = Mock.Create<Guid>();
            Assert.IsNotNull(result);
            Assert.IsFalse(result == Guid.Empty);
        }

        [TestMethod]
        public void MockGuidArray()
        {
            var result = Mock.Create<Guid[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
            Assert.IsFalse(result.Where(g => g == null || g == Guid.Empty).Any());
        }

        [TestMethod]
        public void MockInt()
        {
            var result = Mock.Create<int>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result > int.MinValue && result < int.MaxValue && result != 0);
        }

        [TestMethod]
        public void MockIntArray()
        {
            var result = Mock.Create<int[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockInt64()
        {
            var result = Mock.Create<Int64>();
            Assert.IsNotNull(result);
        }

        [TestMethod]
        public void MockInt64Array()
        {
            var result = Mock.Create<Int64[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockInt16()
        {
            var result = Mock.Create<Int16>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result > Int16.MinValue && result < Int16.MaxValue && result != 0);
        }

        [TestMethod]
        public void MockInt16Array()
        {
            var result = Mock.Create<Int16[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockUInt()
        {
            var result = Mock.Create<uint>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result > uint.MinValue && result < uint.MaxValue && result != 0);
        }

        [TestMethod]
        public void MockUIntArray()
        {
            var result = Mock.Create<uint[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockUInt16()
        {
            var result = Mock.Create<UInt16>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result > UInt16.MinValue && result < UInt16.MaxValue && result != 0);
        }

        [TestMethod]
        public void MockUInt16Array()
        {
            var result = Mock.Create<UInt16[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockUInt32()
        {
            var result = Mock.Create<UInt32>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result > UInt32.MinValue && result < UInt32.MaxValue && result != 0);
        }

        [TestMethod]
        public void MockUInt32Array()
        {
            var result = Mock.Create<UInt32[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockUInt64()
        {
            var result = Mock.Create<UInt64>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result > UInt64.MinValue && result < UInt64.MaxValue && result != 0);
        }

        [TestMethod]
        public void MockUInt64Array()
        {
            var result = Mock.Create<UInt64[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }

        [TestMethod]
        public void MockString()
        {
            var result = Mock.Create<String>();
            Assert.IsNotNull(result);
            Assert.IsFalse(String.IsNullOrEmpty(result));
        }

        [TestMethod]
        public void MockStringArray()
        {
            var result = Mock.Create<String[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
            Assert.IsFalse(result.Where(s => String.IsNullOrEmpty(s)).Any());
        }

        [TestMethod]
        public void MockDateTime()
        {
            var result = Mock.Create<DateTime>();
            Assert.IsNotNull(result);
        }

        [TestMethod]
        public void MockDateTimeArray()
        {
            var result = Mock.Create<DateTime[]>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Length >= 1 && result.Length <= DimMock.Constants.ArrayMax);
        }
    }
}
